package 第六周.homework;
//创造一个方法，在每次引用该方法时将对所有用户增加3%的利息。
import java.text.NumberFormat;
public class pp8_6 {
    private final double RATE = 0.03;

    private long acctNumber;
    private double balance;
    private String name;
    //Sets up the account by defining its owner, account number,
    //and initial balance.
    public pp8_6(String owner,long account,double initial){
        name = owner;
        acctNumber = account;
        balance = initial;
    }
    //Deposits the specified amount into the account.Returns the new balance.
    public double deposit(double amount)
    {
        balance = balance + amount;
        return balance;
    }
    //Withdraws the specified amount from the account and applies the fee.
    //Returns the new balance.
    public double withdraw(double amount , double fee)
    {
        balance = balance - amount -fee;
        return balance;
    }

    public String getName() {
        return name;
    }

    //Adds interest to the account and returns the new balance.
    public double addInterest()
    {
        balance += (balance*RATE);
        return balance;

    }
    //Returns the current balanceof the account.
    public double getBalance()
    {
        return balance;
    }
    //Returns a one-line  description of the account as a string.

    @Override
    public String toString() {
        NumberFormat fmt = NumberFormat.getCurrencyInstance();
        return acctNumber + "\t" + name + "\t" +fmt.format(balance);
    }
}
